{% extends "base.html" %}

{% load i18n %}

{% block head_title %}
	{% trans "Draw form" %}
{% endblock %}

{% block subheader %}
	<h3>Enter all the information for the draw: your friends' names and e-mail addresses, 
		and the message you will all receive, and then the draw will take place automatically.
	</h3>
{% endblock %}

{% block content %}
<form action="." method="POST">
	<div id="in">
		<div id="first_column">
			<table id="player_table">
				<tr><td colspan="4">
					<a href="javascript:jAddPlayer();">{% trans "Add Player" %}</a>
				</td></tr>
				<tr>
					<td>{% trans "Id" %}</td>
					<td>{% trans "Name" %}</td>
					<td>{% trans "Email" %}</td>
					<td>{% trans "Exclusions" %}</td>
				</tr>
			    {{ player_formset.management_form }}
		        {% for form in player_formset.forms %}
					<tr>
						<td>
							{{ forloop.counter }}
				        	<input id="id_form-{{ forloop.counter0 }}-draw_id" type="hidden" name="form-{{ forloop.counter0 }}-draw_id" value="{{ forloop.counter }}"/>
						</td>
						<td>
				        	{{ form.name.errors }}
				        	{{ form.name }}
						</td>
						<td>
				        	{{ form.email.errors }}
				        	{{ form.email }}
						</td>
						<td>
				        	{{ form.exclusion_ids.errors }}
				        	<input id="id_form-{{ forloop.counter0 }}-exclusion_ids" type="text" name="form-{{ forloop.counter0 }}-exclusion_ids" size="5"/>
						</td>
					</tr>
		        {% endfor %}
				<tr id="submit_row"><td>
					<a href="javascript:jAddPlayer();">{% trans "Add Player" %}</a>
				</td></tr>
			</table>
		</div>
		<div id="second_column">
			<ul>
				<li id="help_label">
					<label for="id_subject">{% trans "The subject of the email. The $NAME keyword will be substituted by the email recipient's name" %}</label>
				</li>
				<li>
					<input id="id_subject" type="text" value="$NAME, your secret santa draw" name="subject" size="50" maxlength="50"/>
				</li>
				<li id="help_label">
					<label for="id_body">{% trans "The body of the email. Remember to use at least once the $FRIEND keyword"%}</label>
				</li>
				<li>
					<textarea id="id_body" name="body" cols="40" rows="6">You are to give a gift to $FRIEND</textarea>
				</li>
			</ul>
			<div id="button">
				<input type="submit" value="{% trans "Draw!" %}">
			</div>
		</div>
	</div>
</form>
{% endblock %}